{% extends "base.html" %}

{% block title %}重置密码 - SteHub{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6 col-lg-5">
        <div class="card">
            <div class="card-header">
                <h3 class="text-center mb-0"><i class="fas fa-key me-2"></i>重置密码</h3>
            </div>
            <div class="card-body">
                <p class="text-muted text-center mb-4">
                    请设置您的新密码
                </p>
                
                <form method="POST" action="{{ url_for('auth.reset_password', token=token) }}">
                    <div class="mb-3">
                        <label for="new_password" class="form-label">新密码</label>
                        <input type="password" class="form-control" id="new_password" 
                               name="new_password" required placeholder="至少8位字符" minlength="8">
                        <div class="form-text">密码应包含字母、数字和特殊字符</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="confirm_password" class="form-label">确认新密码</label>
                        <input type="password" class="form-control" id="confirm_password" 
                               name="confirm_password" required placeholder="再次输入新密码">
                    </div>
                    
                    <div class="d-grid gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save me-2"></i>重置密码
                        </button>
                    </div>
                </form>
                
                <div class="text-center mt-4">
                    <p class="mb-0">
                        <a href="{{ url_for('auth.login') }}" class="text-decoration-none">
                            <i class="fas fa-sign-in-alt me-1"></i>返回登录
                        </a>
                    </p>
                </div>
            </div>
        </div>

        <!-- 安全提示 -->
        <div class="card mt-4">
            <div class="card-body">
                <h6><i class="fas fa-shield-alt me-2"></i>安全提示</h6>
                <ul class="small text-muted mb-0">
                    <li>密码重置后，所有设备的登录状态将保持</li>
                    <li>建议在密码重置后检查账户安全</li>
                    <li>如非本人操作，请立即联系管理员</li>
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
document.addEventListener('DOMContentLoaded', function() {
    const newPassword = document.getElementById('new_password');
    const confirmPassword = document.getElementById('confirm_password');
    
    function validatePassword() {
        if (newPassword.value !== confirmPassword.value) {
            confirmPassword.setCustomValidity('密码不一致');
        } else {
            confirmPassword.setCustomValidity('');
        }
    }
    
    newPassword.addEventListener('change', validatePassword);
    confirmPassword.addEventListener('keyup', validatePassword);
});
</script>
{% endblock %}